package com.ucampus.dao;

import com.ucampus.entity.welcomeStatus;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface welcomeStatusMapper {
    @Select("SELECT * FROM user_task_progress WHERE user_id = #{userId} AND status = '未完成'")
    List<welcomeStatus> getIncompleteStatusByUserId(int userId);

    @Insert({
            "<script>",
            "INSERT INTO user_task_progress (user_id, mission, process, status) VALUES ",
            "<foreach collection='missions' item='mission' separator=','>",
            "(#{userId}, #{mission}, 0, '未开始')",
            "</foreach>",
            "</script>"
    })
    void createDefaultTasks(@Param("userId") int userId, @Param("missions") List<String> missions);

    @Update("UPDATE user_task_progress SET process = #{process} WHERE user_id = #{userId} AND mission = #{mission}")
    void updateTaskProgress(@Param("userId") int userId, @Param("mission") String mission, @Param("process") float process);

    @Select("SELECT * FROM user_task_progress WHERE user_id = #{userId} AND mission = #{mission}")
    welcomeStatus getTaskByUserIdAndMission(@Param("userId") int userId, @Param("mission") String mission);
}
